<template>
	<view class="login_wrap">
		<u-button @click="wechat" type="primary" size="medium">微信登录</u-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			wechat() {
				uni.login({
				  provider: 'weixin',
				  success: function (loginRes) {
				    console.log(loginRes.authResult)
					/* 
						"access_token": "45_rTMpjeoNTfaVSHCK92ziKtZhvk0aYjYUMzwwCx3bBE3O3FAEp93Z7-doA5CbI-D6VIWaa0XAjXeCX2ONQFrnAUdMPuCJp0hqdMOK3ITorGA",
						"code": "013hW1000Q9sML1Bxd200Uop3G0hW10T",
						"expires_in": 7200,
						"openid": "oRrdQt2V8PISAIujg7GLlujXTeAg",
						"refresh_token": "45_z59W7YB8AKB6zRnInN-nSHOBLG80AsMEHYuT9q-t1I5aYoUqEAu1TWjajU6JiwLuRR9xvLVzg0chjyhcOyzy-SR9To2n-qyW00TJ_4yXOn4",
						"scope": "snsapi_userinfo",
						"unionid": "oU5Yyt0weqYsD0ZXVwO-SoXdcM5s"
					*/
					uni.getUserInfo({
						provider: 'weixin',
						  success: function (infoRes) {
							console.log(infoRes.userInfo)
							/* 
								"openId": "oRrdQt2V8PISAIujg7GLlujXTeAg",
								"nickName": "云边有个奶茶店",
								"gender": 1,
								"city": "Tianmen",
								"province": "Hubei",
								"country": "China",
								"avatarUrl": "https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83ep69HH6GUu0BuV5YWRlx9xGXibSoG3IgbZM3Do5UwEq4sIIwEtKbjEEt9Cq2CW6Xg4kqwpibEn8naibA/132",
								"unionId": "oU5Yyt0weqYsD0ZXVwO-SoXdcM5s"
							 */
						}
					})
				  }
				})
			}
		}
	};
</script>

<style>
	.login_wrap {
		margin-top: 60rpx;
	}
</style>
